package com.lyf.scm.plan.api.controller;

import com.lyf.scm.plan.api.dto.DirectlyStoreDTO;
import com.lyf.scm.plan.api.dto.DirectlyStoreQueryDTO;
import com.lyf.scm.plan.domain.service.DirectlyStoreService;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.util.controller.RomeController;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * description:
 *
 * @author: haodong
 * @data: 2020/8/29 17:16
 */
@Slf4j
@Api(tags = "直营预测计划--门店")
@RequestMapping("/api/v1/salesPlanDirectlyStore")
@RomeController
public class DirectlyStoreController {

    @Resource
    private DirectlyStoreService directlyStoreService;

    @PostMapping("/list")
    @ApiOperation(value = "按条件查询直营预测计划(天维度)")
    public Response<List<DirectlyStoreDTO>> listBySelective(@RequestBody @Valid DirectlyStoreQueryDTO directlyStoreQueryDTO) {
        return Response.builderSuccess(directlyStoreService.listBySelective(directlyStoreQueryDTO));
    }

    @PostMapping("/updateStatus")
    @ApiOperation(value = "暂存，提交，取消按钮对应的接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "0-暂存1-提交2-取消", required = true, paramType = "query")
    })
    public Response updateStatusAndQty(@RequestBody DirectlyStoreQueryDTO directlyStoreQueryDTO,
                                       @RequestParam("type") Integer type){
        return Response.builderSuccess(directlyStoreService.updateStatusAndQty(directlyStoreQueryDTO,type));
    }

    @PostMapping("/update")
    @ApiOperation(value = "定时修改状态")
    public Response updateStatus(){
        return Response.builderSuccess(directlyStoreService.updateStatus());
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除对应标识数据")
    public Response delete(@RequestParam("opSign") String opSign) {
        directlyStoreService.delete(opSign);
        return Response.builderSuccess(null);
    }
    @PostMapping("/listByCondition")
    @ApiOperation("条件查询")
    public Response listByCondition(@RequestBody DirectlyStoreDTO directlyStore){
        return Response.builderSuccess(directlyStoreService.listByCondition(directlyStore));
    }
}
